<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class ven_vendor_manage extends CI_Controller {


	public function __construct() {
		session_start();
		parent::__construct();
		$this->load->helper("common");
	}

	public function index(){

		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/user_menu");
		$data['user_menu']=$this->user_menu->get_user_menu();

		$this->load->library("common/right_manage");
		$data['query_vendor_draft']	=false;
		if ($this->right_manage->check_right("query_vendor_draft")) {
			$data['query_vendor_draft']	=true;
		}
		$data['delete_vendor_draft']	=false;
		if ($this->right_manage->check_right("delete_vendor_draft")) {
			$data['delete_vendor_draft']=true;
		}
		$data['add_vendor_draft']	=false;
		if ($this->right_manage->check_right("add_vendor_draft")) {
			$data['add_vendor_draft']	=true;
		}
		$data['update_vendor_draft']	=false;
		if ($this->right_manage->check_right("update_vendor_draft")) {
			$data['update_vendor_draft']	=true;
		}
		$data['check_vendor_draft']	=false;
		if ($this->right_manage->check_right("check_vendor_draft")) {
			$data['check_vendor_draft']	=true;
		}
		$data['query_vendor']	=false;
		if ($this->right_manage->check_right("query_vendor")) {
			$data['query_vendor']	=true;
		}
		$data['update_vendor']	=false;
		if ($this->right_manage->check_right("update_vendor")) {
			$data['update_vendor']	=true;
		}
		$this->load->library("ven/vendor_draft");
		$data['vendor_draft_list'] 	=$this->vendor_draft->query_my_vendor_draft_list($_SESSION['user_name'],$_SESSION['user_id']);
		$data['num']	=$this->vendor_draft->query_my_vendor_draft_num($_SESSION['user_name'],$_SESSION['user_id']);


		$this->load->library("sys/region");
		$data['top_regions']	= $this->region->query_user_top_regions($_SESSION['user_id']);

		$this->load->library("tools/pagination");
		$data['page_link']=$this->pagination->get_pagination(base_url()."index.php/ven_vendor_manage?",$data['num']);
		$this->load->view("ven/vendor/vendor_draft_main",$data);
	}

	public function search_vendor_draft(){

		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/user_menu");
		$data['user_menu']=$this->user_menu->get_user_menu();

		$this->load->library("common/right_manage");
		$data['query_vendor_draft']	=false;
		if ($this->right_manage->check_right("query_vendor_draft")) {
			$data['query_vendor_draft']	=true;
		}
		$data['delete_vendor_draft']	=false;
		if ($this->right_manage->check_right("delete_vendor_draft")) {
			$data['delete_vendor_draft']=true;
		}
		$data['add_vendor_draft']	=false;
		if ($this->right_manage->check_right("add_vendor_draft")) {
			$data['add_vendor_draft']	=true;
		}
		$data['update_vendor_draft']	=false;
		if ($this->right_manage->check_right("update_vendor_draft")) {
			$data['update_vendor_draft']	=true;
		}
		$data['check_vendor_draft']	=false;
		if ($this->right_manage->check_right("check_vendor_draft")) {
			$data['check_vendor_draft']	=true;
		}
		$data['query_vendor']	=false;
		if ($this->right_manage->check_right("query_vendor")) {
			$data['query_vendor']	=true;
		}
		$data['update_vendor']	=false;
		if ($this->right_manage->check_right("update_vendor")) {
			$data['update_vendor']	=true;
		}

		$search['province'] 	= $this->input->get("province");
		$search['city']			= $this->input->get("city");
		$search['region'] 		= $this->input->get("region");
		$search['keyword'] 		= $this->input->get("keyword");

		$this->load->library("ven/vendor_draft");
		$data['vendor_draft_list'] 	=$this->vendor_draft->search_my_vendor_draft_list($_SESSION['user_name'],$_SESSION['user_id'],$search);
		$data['num']	=$this->vendor_draft->search_my_vendor_draft_num($_SESSION['user_name'],$_SESSION['user_id'],$search);


		$this->load->library("sys/region");
		$data['top_regions']	= $this->region->query_user_top_regions($_SESSION['user_id']);

		$data['city_list'] =null;
		$data['region_list'] =null;
		if($search['province']){
			$data['city_list'] =$this->region->get_regions($search['province']);

		}
		if($search['city']){
			$data['region_list'] =$this->region->get_regions($search['city']);

		}

		$data['search']=$search;
		$search_url =format_search_url($search);
		$this->load->library("tools/pagination");
		$data['page_link']=$this->pagination->get_pagination(base_url()."index.php/ven_vendor_manage/search_vendor_draft?".$search_url,$data['num']);
		$this->load->view("ven/vendor/search_vendor_draft",$data);
	}

	public function add_vendor_draft(){

		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/user_menu");
		$data['user_menu']=$this->user_menu->get_user_menu();

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("add_vendor_draft")) {
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			$this->load->view("common/error_tip",$data);
			return;
		}

		$this->load->library("sys/region");
		$data['top_regions']	= $this->region->query_user_top_regions($_SESSION['user_id']);

		$this->load->view("ven/vendor/add_vendor_draft",$data);
	}

	public function save_vendor_draft(){
		$this->load->library("common/login_manage");
		if ($this->login_manage->check_login()==false) {
			$data['result']		=false;
			$data['message']	='请您先登录';
			echo json_encode($data);die();
		}
		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("add_vendor_draft")) {
			$result['result']	=false;
			$result['message']	='你没有权限使用这个功能';
			echo json_encode($result);die();
		}
		$vendor['company_name'] =trim($this->input->get_post("company_name"));
		$vendor['province'] =$this->input->get_post("province");
		$vendor['city'] =$this->input->get_post("city");
		$vendor['region'] =$this->input->get_post("region");
		$vendor['registered_capital'] =trim($this->input->get_post("registered_capital"));
		$vendor['registration_time'] =trim($this->input->get_post("registration_time"));
		$vendor['corpscale'] =trim($this->input->get_post("corpscale"));
		$vendor['employees'] =trim($this->input->get_post("employees"));
		$vendor['license_address'] =trim($this->input->get_post("license_address"));
		$vendor['address'] =trim($this->input->get_post("address"));
		$vendor['legal_person'] =trim($this->input->get_post("legal_person"));
		$vendor['boss'] =trim($this->input->get_post("boss"));
		$vendor['phone'] =trim($this->input->get_post("phone"));
		$vendor['fax'] =trim($this->input->get_post("fax"));
		$vendor['highway_media'] =$this->input->get_post("highway_media");
		$vendor['airport_media'] =$this->input->get_post("airport_media");
		$vendor['led_media'] =$this->input->get_post("led_media");
		$vendor['cityad_media'] =$this->input->get_post("cityad_media");
		$vendor['highway_count'] =trim($this->input->get_post("highway_count"));
		$vendor['airport_count'] =trim($this->input->get_post("airport_count"));
		$vendor['led_count'] =trim($this->input->get_post("led_count"));
		$vendor['cityad_count'] =trim($this->input->get_post("cityad_count"));
		$vendor['popularity'] =intval($this->input->get_post("popularity"));
		$vendor['credit'] =intval($this->input->get_post("credit"));
		$vendor['price_type'] =intval($this->input->get_post("price_type"));
		$vendor['decision_type'] =intval($this->input->get_post("decision_type"));
		$vendor['license_valid'] =intval($this->input->get_post("license_valid"));
		$vendor['orgcode_valid'] =intval($this->input->get_post("orgcode_valid"));
		$vendor['tax_valid'] =intval($this->input->get_post("tax_valid"));
		$vendor['background'] =trim($this->input->get_post("background"));

		$vendor['contactsname0'] =trim($this->input->get_post("contactsname0"));
		$vendor['contactspost0'] =trim($this->input->get_post("contactspost0"));
		$vendor['contactsphone0'] =trim($this->input->get_post("contactsphone0"));
		$vendor['contactsname1'] =trim($this->input->get_post("contactsname1"));
		$vendor['contactspost1'] =trim($this->input->get_post("contactspost1"));
		$vendor['contactsphone1'] =trim($this->input->get_post("contactsphone1"));
		$vendor['contactsname2'] =trim($this->input->get_post("contactsname2"));
		$vendor['contactspost2'] =trim($this->input->get_post("contactspost2"));
		$vendor['contactsphone2'] =trim($this->input->get_post("contactsphone2"));

		$vendor['quote']		=$this->input->get_post("quote");
		$vendor['unique_id'] 	=$this->input->get_post("unique_id");

		$vendor['explanation']=$this->input->get_post("explanation");
		$vendor['vendor_draft_type']=$this->input->get_post("vendor_draft_type");

		$this->load->library("ven/vendor_draft");
		$result =$this->vendor_draft->save_vendor_draft($vendor);
		echo JSON($result);
	}

	public function get_vendor_draft(){

		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/user_menu");
		$data['user_menu']=$this->user_menu->get_user_menu();

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("query_vendor_draft")) {
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			$this->load->view("common/error_tip",$data);
			return;
		}

		$vendor_draft_id =$this->input->get("vendor_draft_id");
		$this->load->library("ven/vendor_draft");
		$data['vendor_draft'] =$this->vendor_draft->get_vendor_draft_info($vendor_draft_id);

		$this->load->library("ven/vendor_draft_log");
		$data['logs']=$this->vendor_draft_log->get_logs($vendor_draft_id);

		$this->load->view("ven/vendor/get_vendor_draft",$data);
	}

	public function edit_vendor_draft(){

		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/user_menu");
		$data['user_menu']=$this->user_menu->get_user_menu();

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("update_vendor_draft")) {
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			$this->load->view("common/error_tip",$data);
			return;
		}

		$vendor_draft_id =$this->input->get("vendor_draft_id");
		$this->load->library("ven/vendor_draft");
		$data['vendor_draft'] =$this->vendor_draft->get_vendor_draft_info($vendor_draft_id);

		$this->load->library("sys/region");
		$data['top_regions']	= $this->region->query_user_top_regions($_SESSION['user_id']);
		$data['second_regions'] =null;
		$data['last_regions'] =null;
		if($data['vendor_draft']['city']){
			$data['second_regions'] =$this->region->get_regions($data['vendor_draft']['province']);

		}
		if($data['vendor_draft']['region']){
			$data['last_regions'] =$this->region->get_regions($data['vendor_draft']['city']);

		}

		$this->load->view("ven/vendor/edit_vendor_draft",$data);
	}

	public function update_vendor_draft(){

		$this->load->library("common/login_manage");
		if ($this->login_manage->check_login()==false) {
			$data['result']		=false;
			$data['message']	='请您先登录';
			echo json_encode($data);die();
		}

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("query_vendor_draft")) {
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			echo json_encode($data);die();

		}
		$vendor_draft_id =$this->input->post("vendor_draft_id");
		$vendor['company_name'] =trim($this->input->get_post("company_name"));
		$vendor['province'] =$this->input->get_post("province");
		$vendor['city'] =$this->input->get_post("city");
		$vendor['region'] =$this->input->get_post("region");
		$vendor['registered_capital'] =trim($this->input->get_post("registered_capital"));
		$vendor['registration_time'] =trim($this->input->get_post("registration_time"));
		$vendor['corpscale'] =trim($this->input->get_post("corpscale"));
		$vendor['employees'] =trim($this->input->get_post("employees"));
		$vendor['license_address'] =trim($this->input->get_post("license_address"));
		$vendor['address'] =trim($this->input->get_post("address"));
		$vendor['legal_person'] =trim($this->input->get_post("legal_person"));
		$vendor['boss'] =trim($this->input->get_post("boss"));
		$vendor['phone'] =trim($this->input->get_post("phone"));
		$vendor['fax'] =trim($this->input->get_post("fax"));
		$vendor['highway_media'] =$this->input->get_post("highway_media");
		$vendor['airport_media'] =$this->input->get_post("airport_media");
		$vendor['led_media'] =$this->input->get_post("led_media");
		$vendor['cityad_media'] =$this->input->get_post("cityad_media");
		$vendor['highway_count'] =trim($this->input->get_post("highway_count"));
		$vendor['airport_count'] =trim($this->input->get_post("airport_count"));
		$vendor['led_count'] =trim($this->input->get_post("led_count"));
		$vendor['cityad_count'] =trim($this->input->get_post("cityad_count"));
		$vendor['popularity'] =intval($this->input->get_post("popularity"));
		$vendor['credit'] =intval($this->input->get_post("credit"));
		$vendor['price_type'] =intval($this->input->get_post("price_type"));
		$vendor['decision_type'] =intval($this->input->get_post("decision_type"));
		$vendor['license_valid'] =intval($this->input->get_post("license_valid"));
		$vendor['orgcode_valid'] =intval($this->input->get_post("orgcode_valid"));
		$vendor['tax_valid'] =intval($this->input->get_post("tax_valid"));
		$vendor['background'] =trim($this->input->get_post("background"));

		$vendor['contactsname0'] =trim($this->input->get_post("contactsname0"));
		$vendor['contactspost0'] =trim($this->input->get_post("contactspost0"));
		$vendor['contactsphone0'] =trim($this->input->get_post("contactsphone0"));
		$vendor['contactsname1'] =trim($this->input->get_post("contactsname1"));
		$vendor['contactspost1'] =trim($this->input->get_post("contactspost1"));
		$vendor['contactsphone1'] =trim($this->input->get_post("contactsphone1"));
		$vendor['contactsname2'] =trim($this->input->get_post("contactsname2"));
		$vendor['contactspost2'] =trim($this->input->get_post("contactspost2"));
		$vendor['contactsphone2'] =trim($this->input->get_post("contactsphone2"));

		$vendor['explanation']=$this->input->get_post("explanation");
		$vendor['quote'] =$this->input->get_post("quote");

		$this->load->library("ven/vendor_draft");
		$result =$this->vendor_draft->update_vendor_draft($vendor,$vendor_draft_id);
		echo JSON($result);

	}
	public function delete_vendor_draft(){
		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("delete_vendor_draft")) {
			$this->load->library("common/user_menu");
			$data['user_menu']=$this->user_menu->get_user_menu();
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			$this->load->view("common/error_tip",$data);
			return;
		}
		$this->load->library("ven/vendor_draft");
		$vendor_draft_id	= intval($this->input->get('vendor_draft_id'));
		$this->vendor_draft->delete_vendor_draft($vendor_draft_id);
		echo "<script>history.go(-1)</script>";
	}

	public function submit_check_draft(){
		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("update_vendor_draft")&&$this->right_manage->check_right("add_vendor_draft")) {
			$this->load->library("common/user_menu");
			$data['user_menu']=$this->user_menu->get_user_menu();
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			$this->load->view("common/error_tip",$data);
			return;
		}
		$this->load->library("ven/vendor_draft");
		$vendor_draft_id	= intval($this->input->get('vendor_draft_id'));
		$this->vendor_draft->submit_check_draft($vendor_draft_id);
		echo "<script>history.go(-1)</script>";
	}
	public function check_list(){

		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/user_menu");
		$data['user_menu']=$this->user_menu->get_user_menu();

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("check_vendor_draft")) {
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			$this->load->view("common/error_tip",$data);
			return;
		}

		$this->load->library("ven/vendor_draft");
		$data['vendor_draft_list'] 	=$this->vendor_draft->query_check_vendor_draft_list($_SESSION['user_id']);
		$data['num']	=$this->vendor_draft->query_check_vendor_draft_num($_SESSION['user_id']);

		$this->load->library("sys/region");
		$data['top_regions']	= $this->region->query_user_top_regions($_SESSION['user_id']);

		$this->load->library("tools/pagination");
		$data['page_link']=$this->pagination->get_pagination(base_url()."index.php/ven_vendor_manage/check_list?",$data['num']);
		$this->load->view("ven/vendor/check_list",$data);
	}



	public function search_check_list(){

		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/user_menu");
		$data['user_menu']=$this->user_menu->get_user_menu();

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("check_vendor_draft")) {
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			$this->load->view("common/error_tip",$data);
			return;
		}


		$search['province'] 	= $this->input->get("province");
		$search['city']			= $this->input->get("city");
		$search['region'] 		= $this->input->get("region");
		$search['keyword'] 		= $this->input->get("keyword");

		$this->load->library("ven/vendor_draft");
		$data['vendor_draft_list'] 	=$this->vendor_draft->search_check_vendor_draft_list($_SESSION['user_id'],$search);
		$data['num']				=$this->vendor_draft->search_check_vendor_draft_num($_SESSION['user_id'],$search);

		$this->load->library("sys/region");
		$data['top_regions']	= $this->region->query_user_top_regions($_SESSION['user_id']);
		$data['city_list'] 		= null;
		$data['region_list'] 	= null;
		if($search['province']){
			$data['city_list'] =$this->region->get_regions($search['province']);
		}
		if($search['city']){
			$data['region_list'] =$this->region->get_regions($search['city']);
		}

		$data['search']=$search;
		$search_url =format_search_url($search);
		$this->load->library("tools/pagination");
		$data['page_link']=$this->pagination->get_pagination(base_url()."index.php/ven_vendor_manage/search_vendor_draft?".$search_url,$data['num']);
		$this->load->view("ven/vendor/search_check_list",$data);

	}



	public function to_check_draft(){

		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/user_menu");
		$data['user_menu']=$this->user_menu->get_user_menu();

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("check_vendor_draft")) {
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			$this->load->view("common/error_tip",$data);
			return;
		}


		$vendor_draft_id =$this->input->get("vendor_draft_id");
		$this->load->library("ven/vendor_draft");
		$data['vendor_draft'] =$this->vendor_draft->get_vendor_draft_info($vendor_draft_id);

		$this->load->library("ven/vendor_draft_log");
		$data['logs']=$this->vendor_draft_log->get_logs($vendor_draft_id);

		$this->load->view("ven/vendor/to_check_draft",$data);
	}

	public function allow_draft(){

		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/user_menu");
		$data['user_menu']=$this->user_menu->get_user_menu();

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("check_vendor_draft")) {
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			$this->load->view("common/error_tip",$data);
			return;
		}


		$vendor_draft_id =$this->input->get("vendor_draft_id");
		$this->load->library("ven/vendor_draft");
		$this->vendor_draft->allow_draft($vendor_draft_id);

		redirect(base_url()."index.php/ven_vendor_manage/check_list");
	}


	public function not_allow_draft(){

		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/user_menu");
		$data['user_menu']=$this->user_menu->get_user_menu();

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("check_vendor_draft")) {
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			$this->load->view("common/error_tip",$data);
			return;
		}


		$vendor_draft_id =$this->input->get_post("vendor_draft_id");
		$explanation=trim($this->input->get_post("explanation"));
		$this->load->library("ven/vendor_draft");
		$data['vendor_draft'] =$this->vendor_draft->not_allow_draft($vendor_draft_id,$explanation);


		redirect(base_url()."index.php/ven_vendor_manage/check_list");
	}

	public  function vendor_list(){
		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/user_menu");
		$data['user_menu']=$this->user_menu->get_user_menu();

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("query_vendor")) {
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			$this->load->view("common/error_tip",$data);
			return;
		}
		$this->load->library("sys/region");
		$data['top_regions']	= $this->region->query_user_top_regions($_SESSION['user_id']);

		$this->load->library("ven/vendor");
		$data['vendor_list'] 	=$this->vendor->query_vendor_list($_SESSION['user_id']);
		$data['num']			=$this->vendor->query_vendor_num($_SESSION['user_id']);

		$this->load->library("tools/pagination");
		$data['page_link']=$this->pagination->get_pagination(base_url()."index.php/ven_vendor_manage/vendor_list?",$data['num']);
		$this->load->view("ven/vendor/vendor_list",$data);
	}


	public  function search_vendor_list(){
		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/user_menu");
		$data['user_menu']=$this->user_menu->get_user_menu();

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("query_vendor")) {
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			$this->load->view("common/error_tip",$data);
			return;
		}
		$search['province'] 	= $this->input->get("province");
		$search['city']			= $this->input->get("city");
		$search['region'] 		= $this->input->get("region");
		$search['keyword'] 		= $this->input->get("keyword");

		$this->load->library("ven/vendor");
		$data['vendor_list'] 	=$this->vendor->search_vendor_list($_SESSION['user_id'],$search);
		$data['num']			=$this->vendor->search_vendor_num($_SESSION['user_id'],$search);

		$this->load->library("sys/region");
		$data['top_regions']	= $this->region->query_user_top_regions($_SESSION['user_id']);
		$data['city_list'] 		= null;
		$data['region_list'] 	= null;
		if($search['province']){
			$data['city_list'] =$this->region->get_regions($search['province']);
		}
		if($search['city']){
			$data['region_list'] =$this->region->get_regions($search['city']);
		}

		$data['search']=$search;
		$search_url =format_search_url($search);
		$this->load->library("tools/pagination");
		$data['page_link']=$this->pagination->get_pagination(base_url()."index.php/ven_vendor_manage/search_vendor_list?".$search_url,$data['num']);

		$this->load->view("ven/vendor/search_vendor_list",$data);
	}


	public function edit_vendor() {

		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/user_menu");
		$data['user_menu']=$this->user_menu->get_user_menu();

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("update_vendor_draft")) {
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			$this->load->view("common/error_tip",$data);
			return;
		}


		$vendor_id =$this->input->get("vendor_id");
		$this->load->library("ven/vendor");
		$data['vendor'] =$this->vendor->get_vendor_info($vendor_id);

		$this->load->library("sys/region");
		$data['top_regions']	= $this->region->query_user_top_regions($_SESSION['user_id']);
		$data['second_regions'] =null;
		$data['last_regions'] =null;
		if($data['vendor']['city']){
			$data['second_regions'] =$this->region->get_regions($data['vendor']['province']);

		}
		if($data['vendor']['region']){
			$data['last_regions'] =$this->region->get_regions($data['vendor']['city']);

		}

		$this->load->view("ven/vendor/edit_vendor",$data);
	}
	public function get_vendor(){

		$this->load->library("common/login_manage");
		$this->login_manage->redirect_url_check_login();

		$this->load->library("common/user_menu");
		$data['user_menu']=$this->user_menu->get_user_menu();

		$this->load->library("common/right_manage");
		if (!$this->right_manage->check_right("query_vendor")) {
			$data['title']		="权限不足";
			$data['message']	="你没有权限使用这个功能。";
			$this->load->view("common/error_tip",$data);
			return;
		}

		$vendor_id =$this->input->get("vendor_id");
		$this->load->library("ven/vendor");
		$data['vendor'] =$this->vendor->get_vendor_info($vendor_id);

		$this->load->view("ven/vendor/get_vendor",$data);
	}

	public function get_vendors(){
		$this->load->library("ven/vendor");
		$region =$this->input->get_post("region");
		$vendor =$this->vendor->get_vendors($region);
		echo json_encode($vendor);
	}
}
?>